<template>
  <el-container>
    <el-header>
      <v-header></v-header>
    </el-header>
    <el-main>
      <div class="le-body">
        <el-breadcrumb separator="/">
          <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
          <el-breadcrumb-item><a href="/">忘记密码</a></el-breadcrumb-item>
        </el-breadcrumb>
        <div class="le-fgpass">
          <svg
            t="1610096112297"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="2789"
            width="300"
            height="300"
          >
            <path
              d="M194.461538 409.846154h636.307693c19.692308 0 35.692308 16 35.692307 35.692308v375.384615c0 19.692308-16 35.692308-35.692307 35.692308H194.461538c-19.692308 0-35.692308-16-35.692307-35.692308V445.538462c0-19.692308 16-35.692308 35.692307-35.692308z"
              fill="#80CFF5"
              p-id="2790"
            ></path>
            <path
              d="M843.076923 881.107692H182.153846c-26.461538 0-47.876923-21.538462-47.876923-47.876923V433.230769c0-26.461538 21.538462-47.876923 47.876923-47.876923h660.923077c26.461538 0 47.876923 21.538462 47.876923 47.876923v400c0 26.338462-21.538462 47.876923-47.876923 47.876923zM182.153846 409.846154c-12.923077 0-23.384615 10.461538-23.384615 23.384615v400c0 12.923077 10.461538 23.384615 23.384615 23.384616h660.923077c12.923077 0 23.384615-10.461538 23.384615-23.384616V433.230769c0-12.923077-10.461538-23.384615-23.384615-23.384615H182.153846z"
              fill="#1C1B55"
              p-id="2791"
            ></path>
            <path
              d="M159.507692 791.384615h706.707693v29.538462c0 19.076923-15.384615 34.461538-34.461539 34.461538H193.969231c-19.076923 0-34.461538-15.384615-34.461539-34.461538v-29.538462zM668.307692 595.2l197.907693 125.169231v-23.138462l-177.723077-117.046154z"
              fill="#60BCE8"
              p-id="2792"
            ></path>
            <path
              d="M138.657231 427.544615l15.988923-23.952 262.971077 175.544616-15.990154 23.953231z"
              fill="#1C1B55"
              p-id="2793"
            ></path>
            <path
              d="M150.4 774.030769l-16-24 380.553846-252.184615 368.369231 234.215384-15.384615 24.246154-352.615385-224.123077z"
              fill="#1C1B55"
              p-id="2794"
            ></path>
            <path
              d="M642.830769 611.076923c-4.061538 0-8.246154-1.723077-11.076923-5.169231-5.046154-6.153846-4.307692-15.138462 1.846154-20.307692L843.076923 410.461538c6.153846-5.046154 15.138462-4.307692 20.307692 1.846154 5.046154 6.153846 4.307692 15.138462-1.846153 20.307693L652.061538 607.753846c-2.707692 2.215385-6.030769 3.323077-9.230769 3.323077z"
              fill="#1C1B55"
              p-id="2795"
            ></path>
            <path
              d="M202.215385 741.292308l313.107692-204.061539L813.538462 722.215385 515.323077 561.969231z"
              fill="#D4F1FF"
              p-id="2796"
            ></path>
            <path
              d="M267.076923 470.646154l34.092308-20.8v-42.092308L267.076923 391.507692v-44.8l34.092308-11.815384v-45.169231L267.076923 273.476923V219.076923h58.584615l9.476924 30.276923h45.907692l12.676923-30.276923h38.769231l18.584615 30.276923h44.184615l20.923077-30.276923h43.323077l25.846154 30.276923h42.092308l7.753846-30.276923h142.523077v155.692308l-35.2 14.646154v35.323077l37.784615 17.353846v22.76923L644.184615 577.230769l-130.707692-80.861538-110.769231 73.476923z"
              fill="#FFFFFF"
              p-id="2797"
            ></path>
            <path
              d="M645.415385 607.384615c-2.461538 0-4.923077-0.615385-7.138462-1.96923l-124.184615-76.923077-104.246154 69.16923c-4.676923 3.076923-10.953846 2.953846-15.507692-0.36923l-159.63077-116.8c-3.692308-2.707692-5.661538-7.015385-5.538461-11.446154 0.246154-4.553846 2.584615-8.615385 6.523077-10.953846l38.4-23.261539v-9.846154L247.753846 412.307692c-4.676923-2.215385-7.753846-7.015385-7.753846-12.184615v-63.138462c0-5.784615 3.692308-10.953846 9.107692-12.8l24.984616-8.615384v-8.738462l-26.338462-12.553846c-4.676923-2.215385-7.753846-7.015385-7.753846-12.184615V205.538462c0-7.507692 6.030769-13.538462 13.538462-13.538462h82.092307c5.907692 0 11.2 3.815385 12.923077 9.476923l6.523077 20.8h8l9.230769-22.030769c2.092308-5.046154 7.015385-8.369231 12.43077-8.369231h55.384615c4.676923 0 9.107692 2.461538 11.569231 6.523077l14.523077 23.876923h14.76923l16.861539-24.492308c2.584615-3.692308 6.646154-5.907692 11.2-5.907692h56.615384c3.938462 0 7.753846 1.723077 10.338462 4.8l21.784615 25.6h8.492308l5.169231-20.184615c1.476923-6.030769 6.892308-10.215385 13.169231-10.215385h166.646153c7.507692 0 13.538462 6.030769 13.538462 13.538462v178.215384c0 5.415385-3.323077 10.338462-8.369231 12.430769l-26.707692 11.2 29.784615 13.661539c4.8 2.215385 7.876923 7.015385 7.876923 12.307692v37.784616c0 4.061538-1.846154 7.876923-4.923077 10.461538L654.030769 604.307692c-2.584615 2.092308-5.538462 3.076923-8.615384 3.076923z m-131.692308-108.553846c2.461538 0 4.923077 0.615385 7.138461 1.969231l123.323077 76.307692L780.307692 464.861538v-22.76923L750.4 428.307692c-4.8-2.215385-7.876923-7.015385-7.876923-12.307692v-17.6c0-5.415385 3.323077-10.338462 8.369231-12.430769l26.830769-11.2V219.076923H635.2l-5.169231 20.184615c-1.476923 6.030769-6.892308 10.215385-13.169231 10.215385h-25.230769c-3.938462 0-7.753846-1.723077-10.338461-4.8L559.507692 219.076923h-43.323077l-16.861538 24.492308c-2.584615 3.692308-6.646154 5.907692-11.2 5.907692h-29.538462c-4.676923 0-9.107692-2.461538-11.56923-6.523077L432.492308 219.076923h-38.769231l-9.230769 22.030769c-2.092308 5.046154-7.015385 8.369231-12.43077 8.369231h-26.953846c-5.907692 0-11.2-3.815385-12.923077-9.476923l-6.523077-20.923077H267.076923v54.4l26.338462 12.553846c4.676923 2.215385 7.753846 7.015385 7.753846 12.184616v26.953846c0 5.784615-3.692308 10.953846-9.107693 12.8l-24.984615 8.615384v44.923077l26.338462 12.43077c4.676923 2.215385 7.753846 7.015385 7.753846 12.184615v25.969231c0 4.676923-2.461538 9.107692-6.523077 11.56923L267.076923 470.646154 402.707692 569.846154l103.507693-68.8c2.338462-1.353846 4.923077-2.215385 7.507692-2.215385z m-226.092308-56.492307z"
              fill="#1C1B55"
              p-id="2798"
            ></path>
            <path
              d="M295.261538 454.153846l97.353847 79.138462 119.384615-75.2 126.153846 75.2 106.215385-108.923077 35.076923 18.707692v22.153846l-135.384616 112.369231L512 494.276923l-107.938462 78.769231-132.553846-103.261539z"
              fill="#D4F1FF"
              p-id="2799"
            ></path>
            <path
              d="M734.769231 347.076923c52.307692 0 94.769231-42.461538 94.769231-94.769231s-42.461538-94.769231-94.769231-94.76923c-10.215385 0-20.061538 1.6-29.292308 4.676923-9.353846 3.076923-18.092308 7.507692-25.969231 13.16923-24 17.107692-39.507692 45.169231-39.507692 76.923077 0 52.307692 42.461538 94.769231 94.769231 94.769231z"
              fill="#FFF7A6"
              p-id="2800"
            ></path>
            <path
              d="M734.769231 373.538462c-66.830769 0-121.230769-54.4-121.230769-121.23077 0-38.892308 18.830769-75.692308 50.461538-98.461538 10.215385-7.384615 21.415385-13.046154 33.230769-16.861539 12.061538-3.938462 24.738462-5.907692 37.538462-5.907692 66.830769 0 121.230769 54.4 121.230769 121.230769s-54.4 121.230769-121.230769 121.23077z m0-216c-9.969231 0-19.938462 1.6-29.292308 4.676923-9.230769 3.076923-17.969231 7.507692-25.969231 13.16923C654.769231 193.107692 640 221.907692 640 252.307692c0 52.307692 42.461538 94.769231 94.769231 94.769231s94.769231-42.461538 94.769231-94.769231-42.461538-94.769231-94.769231-94.76923z"
              fill="#1C1B55"
              p-id="2801"
            ></path>
            <path
              d="M716.430769 302.646154c-3.2 0-6.523077-1.107692-9.107692-3.323077l-37.046154-30.523077c-6.153846-5.046154-7.015385-14.153846-1.969231-20.307692s14.153846-7.015385 20.307693-1.969231l26.830769 22.030769 63.015384-64.615384c5.538462-5.661538 14.646154-5.784615 20.307693-0.246154s5.784615 14.646154 0.246154 20.307692l-72.246154 74.092308c-2.830769 3.076923-6.523077 4.553846-10.338462 4.553846z"
              fill="#1C1B55"
              p-id="2802"
            ></path>
            <path
              d="M351.630769 302.769231h194.338462"
              fill="#FFFFFF"
              p-id="2803"
            ></path>
            <path
              d="M545.969231 317.169231H351.630769c-8 0-14.4-6.4-14.4-14.4s6.4-14.4 14.4-14.4h194.338462c8 0 14.4 6.4 14.4 14.4s-6.4 14.4-14.4 14.4z"
              fill="#D4F1FF"
              p-id="2804"
            ></path>
            <path
              d="M351.630769 364.307692h233.230769"
              fill="#FFFFFF"
              p-id="2805"
            ></path>
            <path
              d="M584.861538 378.707692H351.630769c-8 0-14.4-6.4-14.4-14.4s6.4-14.4 14.4-14.4h233.230769c8 0 14.4 6.4 14.4 14.4s-6.4 14.4-14.4 14.4z"
              fill="#D4F1FF"
              p-id="2806"
            ></path>
            <path
              d="M351.630769 425.846154h90.953846m35.815385 0h37.907692"
              fill="#FFFFFF"
              p-id="2807"
            ></path>
            <path
              d="M516.307692 440.246154h-37.907692c-8 0-14.4-6.4-14.4-14.4s6.4-14.4 14.4-14.4h37.907692c8 0 14.4 6.4 14.4 14.4s-6.4 14.4-14.4 14.4z m-73.723077 0h-90.953846c-8 0-14.4-6.4-14.4-14.4s6.4-14.4 14.4-14.4h90.953846c8 0 14.4 6.4 14.4 14.4s-6.4 14.4-14.4 14.4z"
              fill="#D4F1FF"
              p-id="2808"
            ></path>
          </svg>
          <p>{{ msg }}</p>
        </div>
      </div>
    </el-main>
    <el-footer> </el-footer>
  </el-container>
</template>

<script>
import header from '@/components/Header'
import crypto from '@/commn/crypto'

export default {
  name: 'ResetPasswordDone',
  components: {
    'v-header': header
  },
  data () {
    return {
      emailContentF:
        '尊敬的易考用户:<br/>' +
        '您好！<br/>' +
        '您在访问易考时进行了重置密码操作，这是一封确认邮件。<br/>' +
        '您可以通过点击以下链接重置帐户密码:<br/>',
      emailContentB:
        '<br/>为保障您的帐号安全，请在24小时内点击该链接，您也可以将链接复制到浏览器地址栏访问。<br/>' +
        '若如果您并未尝试修改密码，请忽略本邮件，由此给您带来的不便请谅解。<br/>',
      msg: '重置密码邮件发送中。请稍后..'
    }
  },
  created () {
    let emailParams = this.$route.params
    let host = window.location.protocol + '//' + window.location.host
    let emailObj = {
      email: emailParams.email,
      date: this.getTime()
    }
    let zipData = crypto.jiami(JSON.stringify(emailObj))
    let url = host + '/account/password/reset/key/' + zipData
    let that = this
    let param = new URLSearchParams()
    param.append('toUsername', emailParams.email)
    param.append('title', '[乐考] 密码重置')
    param.append('content', this.emailContentF + url + this.emailContentB)
    let stindex = 0
    let originmsg = this.msg
    let repeatstr = (str, num) => str.repeat(num)
    let displayst = setInterval(() => {
      const appendstr = repeatstr('.', stindex % 6)
      const displaystr = originmsg + appendstr
      this.msg = displaystr
      stindex++
    }, 300)
    this.$axios
      .post(that.getApi('/email/html'), param)
      .then(function (response) {
        clearInterval(displayst)
        console.log(response)
        if (response === 'success') {
          that.msg = '密码重设链接邮件已发送到您的邮箱,请注意查收并设置密码'
        } else {
          that.msg = '重置密码邮件发送失败！请重试。'
        }
      })
      .catch(function (error) {
        console.log(error)
        that.msg = '重置密码邮件发送失败！请检查网络连接。'
      })
  },
  methods: {
    getTime: function () {
      let yy = new Date().getFullYear()
      var mm =
        new Date().getMonth() < 10
          ? '0' + (new Date().getMonth() + 1)
          : new Date().getMonth() + 1
      var dd =
        new Date().getDate() < 10
          ? '0' + new Date().getDate()
          : new Date().getDate()
      let hh = new Date().getHours()
      let mf =
        new Date().getMinutes() < 10
          ? '0' + new Date().getMinutes()
          : new Date().getMinutes()
      let ss =
        new Date().getSeconds() < 10
          ? '0' + new Date().getSeconds()
          : new Date().getSeconds()
      let gettime = yy + '-' + mm + '-' + dd + ' ' + hh + ':' + mf + ':' + ss
      return gettime
    }
  }
}
</script>

<style scoped>
.le-title {
  font-family: 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
  font-size: 20px;
}
.le-body {
  width: 100%;
  height: 80vh;
}
.le-h1 {
  margin-top: 5rem;
  font-size: 2.2rem;
  font-family: 'Helvetica Neue', 'Hiragino Sans GB', 'Segoe UI',
    'Microsoft Yahei', '微软雅黑', Tahoma, Arial, STHeiti, sans-serif;
  color: #409eff;
}
.le-fgpass {
  margin: 0 auto;
  margin-top: 50px;
  width: 600px;
  text-align: center;
}
</style>
